package com.jxgk.application.controller;

import com.jxgk.application.mapper.EtcMapper;
import com.jxgk.application.pojo.Etc;
import com.jxgk.application.service.EtcService;
import org.apache.catalina.User;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/etc")
public class EtcController {
    @Autowired
    private EtcService etcService;


    @RequestMapping("/findAll")
    public String findAll(Model model){
       List<Etc> etc =  etcService.findAll();
       model.addAttribute("etc",etc);
       return "all";
    }

    @RequestMapping("add")
      public String add( Etc etc){
        etcService.add(etc);
        return "redirect:/etc/findAll";
    }

    @RequestMapping("toadd")
    public String toadd(){
        return "add";
    }
    @RequestMapping("del")
        public String del(Integer rid){
        etcService.del(rid);
        return "redirect:/etc/findAll";
    }



    @RequestMapping("update")
    public String update( Etc etc){
        etcService.update(etc);
        return "redirect:/etc/findAll";
    }

    @RequestMapping("fid")
   public  String  fid(Integer rid,Model model){
        Etc etc =  etcService.fid(rid);
        model.addAttribute("etc",etc);
        return "update";
    }


}
